#include "StdAfx.h"
#include "..\WMP\Common.h"
#include "WMPPlusHook.h"
#include <wmpplug.h>

#pragma unmanaged

WMPPlugin::WMPPlugin(REFCLSID clsid, IWMPPluginUI *plugin) {
	this->clsid = clsid;
	this->plugin = plugin;
}

HRESULT STDMETHODCALLTYPE WMPPlugin::QueryInterface(REFIID riid, void **ppvObject) {
	return plugin->QueryInterface(riid, ppvObject);
}

ULONG STDMETHODCALLTYPE WMPPlugin::AddRef() {
	return plugin->AddRef();
}

ULONG STDMETHODCALLTYPE WMPPlugin::Release() {
	return plugin->Release();
}

HRESULT STDMETHODCALLTYPE WMPPlugin::SetCore(IWMPCore *core) {
	HRESULT ret = plugin->SetCore(core);
	Host->SetupPlugin(clsid, !core);
	return ret;
}

HRESULT STDMETHODCALLTYPE WMPPlugin::Create(HWND hwndParent, HWND *phwndWindow) {
	return plugin->Create(hwndParent, phwndWindow);
}

HRESULT STDMETHODCALLTYPE WMPPlugin::Destroy() {
	return plugin->Destroy();
}

HRESULT STDMETHODCALLTYPE WMPPlugin::DisplayPropertyPage(HWND hwndParent) {
	return plugin->DisplayPropertyPage(hwndParent);
}

HRESULT STDMETHODCALLTYPE WMPPlugin::GetProperty(const WCHAR *pwszName, VARIANT *pvarProperty) {
	return plugin->GetProperty(pwszName, pvarProperty);
}

HRESULT STDMETHODCALLTYPE WMPPlugin::SetProperty(const WCHAR *pwszName, const VARIANT *pvarProperty) {
	return plugin->SetProperty(pwszName, pvarProperty);
}

HRESULT STDMETHODCALLTYPE WMPPlugin::TranslateAccelerator(LPMSG lpmsg) {
	return plugin->TranslateAccelerator(lpmsg);
}

IWMPPluginUI* WrapPlugin(REFCLSID clsid, IWMPPluginUI *plugin) {
	WMPPlugin *wrap = new WMPPlugin(clsid, plugin);
	Host->CreatePlugin(clsid, wrap, plugin);
	return wrap;
};
